home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Gobby 0.4.7 / gobby-0.4.7.exe / {app} / share / gtksourceview-2.0 / language-specs / sh.lang < prev    next >
Extensible Markup Language  |  2008-09-09  |  14KB  |  415 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.  Author: Silian Della Ragione <silian87@gechi.it>
  5.  Copyright (C) 2005 Silian Della Ragione <silian87@gechi.it>
  6.  Copyright (C) 2008 Steve Fr├⌐cinaux <code@istique.net>
  7.  
  8.  This library is free software; you can redistribute it and/or
  9.  modify it under the terms of the GNU Library General Public
  10.  License as published by the Free Software Foundation; either
  11.  version 2 of the License, or (at your option) any later version.
  12.  
  13.  This library is distributed in the hope that it will be useful,
  14.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  Library General Public License for more details.
  17.  
  18.  You should have received a copy of the GNU Library General Public
  19.  License along with this library; if not, write to the
  20.  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21.  Boston, MA 02111-1307, USA.
  22.  
  23. -->
  24. <language id="sh" _name="sh" version="2.0" _section="Scripts">
  25.   <metadata>
  26.     <property name="mimetypes">text/x-shellscript;application/x-shellscript;text/x-sh</property>
  27.     <property name="globs">*.sh</property>
  28.     <property name="line-comment-start">#</property>
  29.   </metadata>
  30.  
  31.   <styles>
  32.     <style id="comment"             _name="Comment"             map-to="def:comment"/>
  33.     <style id="shebang"             _name="Shebang"             map-to="def:shebang"/>
  34.     <style id="function"            _name="Function"            map-to="def:function"/>
  35.     <style id="string"              _name="String"              map-to="def:string"/>
  36.     <style id="keyword"             _name="Keyword"             map-to="def:keyword"/>
  37.     <style id="variable"            _name="Variable"            map-to="def:type"/> <!-- FIXME: need to sort out proper styles for variables -->
  38.     <style id="variable-definition" _name="Variable Definition" map-to="sh:variable"/>
  39.     <style id="others"              _name="Others"              map-to="def:keyword"/>
  40.     <style id="common-command"      _name="Common Commands"     map-to="def:keyword"/>
  41.     <style id="here-doc-bound"      _name="Heredoc Bound"       map-to="def:keyword"/>
  42.     <style id="subshell"            _name="Subshell"            map-to="def:preprocessor"/>
  43.   </styles>
  44.  
  45.   <definitions>
  46.  
  47.     <!-- we cannot use def:shell-like-comment, because
  48.          m4.lang needs to replace this context -->
  49.     <context id="line-comment" style-ref="comment" end-at-line-end="true">
  50.       <start>(?<!\S)#</start>
  51.       <include>
  52.         <context ref="def:in-comment"/>
  53.       </include>
  54.     </context>
  55.  
  56.     <context id="double-quoted-string" style-ref="string">
  57.       <start>"</start>
  58.       <end>"</end>
  59.       <include>
  60.         <!-- highlight escaped chars -->
  61.         <context style-ref="def:special-char">
  62.             <match>\\[$`"\\]</match>
  63.         </context>
  64.         <!-- skip backslash where it's not an escaping char -->
  65.         <context>
  66.             <match>\\</match>
  67.         </context>
  68.         <context ref="def:line-continue"/>
  69.     <context ref="variable"/>
  70.     <context ref="backtick-subshell"/>
  71.       </include>
  72.     </context>
  73.  
  74.     <context id="single-quoted-string" style-ref="string">
  75.       <start>'</start>
  76.       <end>'</end>
  77.     </context>
  78.  
  79.     <context id="subshell">
  80.       <start>\(</start>
  81.       <end>\)</end>
  82.       <include>
  83.         <context sub-pattern="0" where="start" style-ref="keyword"/>
  84.         <context sub-pattern="0" where="end" style-ref="keyword"/>
  85.         <context ref="sh"/>
  86.       </include>
  87.     </context>
  88.  
  89.     <context id="backtick-subshell" style-ref="subshell">
  90.       <start>`</start>
  91.       <end>`</end>
  92.       <include>
  93.         <context ref="def:escape"/>
  94.         <context ref="def:line-continue"/>
  95.         <context ref="variable"/>
  96.         <context ref="built-in-command"/>
  97.         <context ref="common-command"/>
  98.         <context ref="single-quoted-string"/>
  99.         <context ref="double-quoted-string"/>
  100.       </include>
  101.     </context>
  102.  
  103.     <context id="punctuator" style-ref="others">
  104.       <match>[;\|&/]</match>
  105.     </context>
  106.  
  107.     <context id="function" style-ref="function">
  108.       <match>\b[a-zA-Z_][a-zA-Z0-9_]+[ \t]*\(\)</match>
  109.     </context>
  110.  
  111.     <context id="redirection" style-ref="others">
  112.       <keyword>>&+[0-9]</keyword>
  113.       <keyword>\b[0-9]+>&</keyword>
  114.       <keyword>\b[0-9]+>&+[0-9]</keyword>
  115.       <keyword>\b[0-9]+></keyword>
  116.       <keyword>>></keyword>
  117.       <keyword>\b[0-9]+>></keyword>
  118.       <keyword><&[0-9]</keyword>
  119.       <keyword>\b[0-9]+<&</keyword>
  120.       <keyword>\b[0-9]+<&[0-9]</keyword>
  121.       <keyword>\b[0-9]+<</keyword>
  122.       <keyword><<+[0-9]</keyword>
  123.       <keyword>\b[0-9]+<<</keyword>
  124.     </context>
  125.  
  126.     <context id="here-doc">
  127.       <start extended="true" dupnames="true">
  128.         # (?<!<) and [^\s<] are for not matching
  129.         # here-word (<<<)
  130.         (?<!<)
  131.         <<-?\s*\\?(
  132.           \"(?P<HDB>[^\s<]+)\" | # "EOF"
  133.           \'(?P<HDB>[^\s<]+)\' | # 'EOF'
  134.           (?P<HDB>[^\s<]+)       # EOF
  135.         )$
  136.       </start>
  137.       <end>^\t*\%{HDB@start}$</end>
  138.       <include>
  139.         <context sub-pattern="0" where="start" style-ref="here-doc-bound"/>
  140.         <context sub-pattern="0" where="end" style-ref="here-doc-bound"/>
  141.       </include>
  142.     </context>
  143.  
  144.     <context id="operator" style-ref="function">
  145.       <keyword>\-a\b</keyword>
  146.       <keyword>\-b\b</keyword>
  147.       <keyword>\-c\b</keyword>
  148.       <keyword>\-d\b</keyword>
  149.       <keyword>\-e\b</keyword>
  150.       <keyword>\-f\b</keyword>
  151.       <keyword>\-g\b</keyword>
  152.       <keyword>\-h\b</keyword>
  153.       <keyword>\-k\b</keyword>
  154.       <keyword>\-p\b</keyword>
  155.       <keyword>\-r\b</keyword>
  156.       <keyword>\-s\b</keyword>
  157.       <keyword>\-t\b</keyword>
  158.       <keyword>\-u\b</keyword>
  159.       <keyword>\-w\b</keyword>
  160.       <keyword>\-x\b</keyword>
  161.       <keyword>\-O\b</keyword>
  162.       <keyword>\-G\b</keyword>
  163.       <keyword>\-L\b</keyword>
  164.       <keyword>\-S\b</keyword>
  165.       <keyword>\-N\b</keyword>
  166.       <keyword>\-nt\b</keyword>
  167.       <keyword>\-ot\b</keyword>
  168.       <keyword>\-ef\b</keyword>
  169.       <keyword>\-o\b</keyword>
  170.       <keyword>\-z\b</keyword>
  171.       <keyword>\-n\b</keyword>
  172.       <keyword><</keyword>
  173.       <keyword>></keyword>
  174.       <keyword>\!=</keyword>
  175.       <keyword>\-eq\b</keyword>
  176.       <keyword>\-ne\b</keyword>
  177.       <keyword>\-lt\b</keyword>
  178.       <keyword>\-le\b</keyword>
  179.       <keyword>\-gt\b</keyword>
  180.       <keyword>\-ge\b</keyword>
  181.     </context>
  182.  
  183.     <context id="variable" style-ref="variable">
  184.       <match>\$+[!@?*#\${a-zA-Z0-9_][}a-zA-Z0-9_]*</match>
  185.     </context>
  186.  
  187.     <context id="variable-definition">
  188.       <match>(^|(?<=then|else|do|export))\s*([a-zA-Z_][a-zA-Z0-9_]*)\=</match>
  189.       <include>
  190.         <context sub-pattern="2" style-ref="variable-definition"/>
  191.       </include>
  192.     </context>
  193.  
  194.     <context id="built-in-command-1" style-ref="keyword">
  195.       <prefix></prefix>
  196.       <suffix></suffix>
  197.       <keyword>\!</keyword>
  198.       <keyword>\{</keyword>
  199.       <keyword>\}</keyword>
  200.       <keyword>\:</keyword>
  201.       <keyword>(?<=\s)\.(?=\s)</keyword>
  202.     </context>
  203.  
  204.     <context id="for-command">
  205.       <start>\bfor\b</start>
  206.       <end>\b(in|do)\b</end>
  207.       <include>
  208.         <context sub-pattern="0" where="start" style-ref="keyword"/>
  209.         <context sub-pattern="0" where="end" style-ref="keyword"/>
  210.         <context style-ref="variable-definition" once-only="true">
  211.           <match>\w+</match>
  212.         </context>
  213.       </include>
  214.     </context>
  215.  
  216.     <context id="built-in-command-2" style-ref="keyword">
  217.       <prefix>(?<![^\s;\(\)])</prefix>
  218.       <suffix>(?![^\s;\(\)])</suffix>
  219.       <keyword>do</keyword>
  220.       <keyword>done</keyword>
  221.       <keyword>elif</keyword>
  222.       <keyword>else</keyword>
  223.       <keyword>else</keyword>
  224.       <keyword>fi</keyword>
  225.       <keyword>for</keyword>
  226.       <keyword>function</keyword>
  227.       <keyword>if</keyword>
  228.       <keyword>in</keyword>
  229.       <keyword>select</keyword>
  230.       <keyword>then</keyword>
  231.       <keyword>until</keyword>
  232.       <keyword>while</keyword>
  233.       <keyword>bash</keyword>
  234.       <keyword>alias</keyword>
  235.       <keyword>bg</keyword>
  236.       <keyword>bind</keyword>
  237.       <keyword>break</keyword>
  238.       <keyword>builtin</keyword>
  239.       <keyword>cd</keyword>
  240.       <keyword>command</keyword>
  241.       <keyword>compgen</keyword>
  242.       <keyword>complete</keyword>
  243.       <keyword>continue</keyword>
  244.       <keyword>declare</keyword>
  245.       <keyword>dirs</keyword>
  246.       <keyword>disown</keyword>
  247.       <keyword>echo</keyword>
  248.       <keyword>enable</keyword>
  249.       <keyword>eval</keyword>
  250.       <keyword>exec</keyword>
  251.       <keyword>exit</keyword>
  252.       <keyword>export</keyword>
  253.       <keyword>fc</keyword>
  254.       <keyword>fg</keyword>
  255.       <keyword>getopts</keyword>
  256.       <keyword>hash</keyword>
  257.       <keyword>help</keyword>
  258.       <keyword>history</keyword>
  259.       <keyword>jobs</keyword>
  260.       <keyword>kill</keyword>
  261.       <keyword>let</keyword>
  262.       <keyword>local</keyword>
  263.       <keyword>logout</keyword>
  264.       <keyword>podp</keyword>
  265.       <keyword>printf</keyword>
  266.       <keyword>pushd</keyword>
  267.       <keyword>pwd</keyword>
  268.       <keyword>read</keyword>
  269.       <keyword>readonly</keyword>
  270.       <keyword>return</keyword>
  271.       <keyword>set</keyword>
  272.       <keyword>shift</keyword>
  273.       <keyword>shopt</keyword>
  274.       <keyword>source</keyword>
  275.       <keyword>suspend</keyword>
  276.       <keyword>test</keyword>
  277.       <keyword>times</keyword>
  278.       <keyword>trap</keyword>
  279.       <keyword>type</keyword>
  280.       <keyword>typeset</keyword>
  281.       <keyword>ulimit</keyword>
  282.       <keyword>umask</keyword>
  283.       <keyword>unalias</keyword>
  284.       <keyword>unset</keyword>
  285.       <keyword>wait</keyword>
  286.     </context>
  287.  
  288.     <context id="built-in-command">
  289.       <include>
  290.         <context ref="built-in-command-1"/>
  291.         <context ref="for-command"/>
  292.         <context ref="built-in-command-2"/>
  293.       </include>
  294.     </context>
  295.  
  296.     <context id="common-command" style-ref="common-command">
  297.       <prefix>(?<![\w\-\.])</prefix>
  298.       <suffix>(?![\w\-\.])</suffix>
  299.       <keyword>cp</keyword>
  300.       <keyword>rm</keyword>
  301.       <keyword>mv</keyword>
  302.       <keyword>which</keyword>
  303.       <keyword>cat</keyword>
  304.       <keyword>grep</keyword>
  305.       <keyword>sed</keyword>
  306.       <keyword>awk</keyword>
  307.       <keyword>mkdir</keyword>
  308.       <keyword>rmdir</keyword>
  309.       <keyword>ls</keyword>
  310.       <keyword>ps</keyword>
  311.       <keyword>killall</keyword>
  312.       <keyword>pidof</keyword>
  313.       <keyword>diff</keyword>
  314.       <keyword>head</keyword>
  315.       <keyword>tail</keyword>
  316.       <keyword>chown</keyword>
  317.       <keyword>chmod</keyword>
  318.       <keyword>dd</keyword>
  319.       <keyword>find</keyword>
  320.       <keyword>locate</keyword>
  321.       <keyword>tar</keyword>
  322.       <keyword>gunzip</keyword>
  323.       <keyword>gzip</keyword>
  324.       <keyword>bunzip2</keyword>
  325.       <keyword>bzip2</keyword>
  326.       <keyword>zip</keyword>
  327.       <keyword>unzip</keyword>
  328.       <keyword>mount</keyword>
  329.       <keyword>umount</keyword>
  330.       <keyword>sh</keyword>
  331.       <keyword>clear</keyword>
  332.       <keyword>wget</keyword>
  333.       <keyword>date</keyword>
  334.       <keyword>dir</keyword>
  335.       <keyword>du</keyword>
  336.       <keyword>expr</keyword>
  337.       <keyword>su</keyword>
  338.       <keyword>passwd</keyword>
  339.       <keyword>man</keyword>
  340.       <keyword>info</keyword>
  341.       <keyword>id</keyword>
  342.       <keyword>ifconfig</keyword>
  343.       <keyword>gcc</keyword>
  344.       <keyword>make</keyword>
  345.       <keyword>ld</keyword>
  346.       <keyword>ln</keyword>
  347.       <keyword>lsmod</keyword>
  348.       <keyword>insmod</keyword>
  349.       <keyword>modprobe</keyword>
  350.       <keyword>less</keyword>
  351.       <keyword>more</keyword>
  352.       <keyword>patch</keyword>
  353.       <keyword>ping</keyword>
  354.       <keyword>pkg-config</keyword>
  355.       <keyword>nice</keyword>
  356.       <keyword>renice</keyword>
  357.       <keyword>file</keyword>
  358.       <keyword>sudo</keyword>
  359.       <keyword>beep</keyword>
  360.       <keyword>tempfile</keyword>
  361.       <keyword>touch</keyword>
  362.       <keyword>eject</keyword>
  363.       <keyword>uname</keyword>
  364.       <keyword>uptime</keyword>
  365.       <keyword>whoami</keyword>
  366.       <keyword>who</keyword>
  367.       <keyword>whereis</keyword>
  368.       <keyword>sleep</keyword>
  369.       <keyword>dialog</keyword>
  370.       <keyword>xdialog</keyword>
  371.       <keyword>zenity</keyword>
  372.       <keyword>sort</keyword>
  373.       <keyword>uniq</keyword>
  374.     </context>
  375.  
  376.     <context id="case">
  377.       <start>\bcase\b</start>
  378.       <end>\besac\b</end>
  379.       <include>
  380.         <context sub-pattern="0" where="start" style-ref="keyword"/>
  381.         <context sub-pattern="0" where="end" style-ref="keyword"/>
  382.         <context ref="double-quoted-string"/>
  383.         <context ref="single-quoted-string"/>
  384.         <context style-ref="others">
  385.           <match>[^\)\s]+\s*\)|;;</match>
  386.         </context>
  387.         <context ref="sh"/>
  388.       </include>
  389.     </context>
  390.  
  391.     <context id="sh">
  392.       <include>
  393.         <context ref="def:shebang" style-ref="shebang"/>
  394.         <context ref="line-comment"/>
  395.         <context ref="def:escape"/>
  396.         <context ref="single-quoted-string"/>
  397.         <context ref="double-quoted-string"/>
  398.         <context ref="subshell"/>
  399.         <context ref="backtick-subshell"/>
  400.         <context ref="case"/>
  401.         <context ref="punctuator"/>
  402.         <context ref="function"/>
  403.         <context ref="here-doc"/>
  404.         <context ref="redirection"/>
  405.         <context ref="operator"/>
  406.         <context ref="variable"/>
  407.         <context ref="variable-definition"/>
  408.         <context ref="built-in-command"/>
  409.         <context ref="common-command"/>
  410.       </include>
  411.     </context>
  412.  
  413.   </definitions>
  414. </language>
  415.